<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

$category = new Category_model();
//sản phẩm đã xem
$strip = str_replace(".", "-", $this->client_ip);
$itemviewed = isset($_COOKIE["$strip-itemviewed"])?$_COOKIE["$strip-itemviewed"]:"";//print_r($_COOKIE["$strip-itemviewed"]);exit;
$itemviewed = explode(";", $itemviewed);
$arrviewed = array();
foreach($itemviewed as $item)
{
    if($item!='')
    {
        $new = new News_model();
        $news->where('id', $item);
        $news->get(1);
        $arrviewed[] = array(
                            "title"=>$news->title,
                            "image"=>$news->image,
                            "category_id"=>$news->category_id,
                            "code"=>$news->code,
                            "category_code"=>$category->get_title_category_id($news->category_id)->code,
                            "parent_code"=>$category->get_parent_category($news->category_id)->code
        ); 
    }
}
//print_r($arrviewed);exit;
$this->smarty->assign('itemviewed',$arrviewed)
                ->view('frontend/subs/viewed_product');
?>
